package com.bit.silverstar;

import java.util.ArrayList;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class CharAdapter extends BaseAdapter{
	private Context context;
	private ArrayList<IChar> arSrc;
	int[] picture = {R.drawable.character1,R.drawable.character2,R.drawable.character3,R.drawable.character4};
	String[] title = {};
	public CharAdapter(Context context, int gridIchar, ArrayList<IChar> arData){
		this.context = context;
		this.arSrc = arData;
	}
	@Override
	public int getCount() {
		return arSrc.size();
	}

	@Override
	public Object getItem(int position) {
		return arSrc.get(position).toString();
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView im;
		if(convertView==null){
			im=new ImageView(context);
			im.setAdjustViewBounds(true);
			im.setScaleType(ImageView.ScaleType.CENTER_CROP);
		} else{
			im = (ImageView)convertView;
		}
		im.setImageResource(picture[position%4]);
		return im;
	}
	
}
